package cn.krund.lyc.hotlerobot.mapmanage.view;

import android.graphics.Bitmap;
import android.util.LruCache;
import android.widget.ImageView;

import cn.krund.lyc.hotlerobot.mapmanage.draw.IDrawMapFactory;

/**
 * @包名: cn.krund.lyc.hotlerobot.activity.view.uihandler
 * @作者: 刘育成
 * @时间: 2018/3/30  18:55
 * @org: 克路德人工智能
 * @描述: TODO
 * @fileName: MapBitmapView
 */

public class MapBitmapView extends LruCache<String, Bitmap> {
    private static final int HANDLER_MESSAGE_UPDATE_MAP = 1;                                        // 更新地图的消息
    private static final int MAX_CACHE = 50 * 1024 * 1024;                                               // 最大缓存
    private ImageView ivMap;
    private IDrawMapFactory drawMapFactory;

    private boolean isHandler = false;

    private Bitmap bmpForeground, bmpSrc, bmpNewSrc, bmpMap = null;
    public MapBitmapView(ImageView view) {
        super(MAX_CACHE);
        this.ivMap=view;
    }

    public Bitmap getSrcMapBitmap() {
        return this.bmpSrc;
    }

    public void setSrcMapBitmap(Bitmap srcMapBitmap) {
        this.bmpSrc = srcMapBitmap;
    }

    public Bitmap getForegroundBmp() {
        return this.bmpForeground;
    }

    public void setForegroundBmp(Bitmap foregroundBmp) {
        this.bmpForeground = foregroundBmp;
    }





    /**
     * 清楚图片缓存
     */
    public void RecycleBmp() {
        if (bmpMap == null) return;
        boolean isRecycled = bmpMap.isRecycled();//图片是否回收了
        if (!isRecycled) {
            bmpMap.recycle();//回收图片所占用的内存
            System.gc();//提醒系统及时回收
        }
    }
}
